﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace UAXInversionesWeb
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            bool result = Proxy.solicitudAlta(TextoSolicitud.Text);
            if (result)
            {
                Response.Write("<script>alert('Solicitud enviada a " + TextoSolicitud.Text + "')</script>");
            }
            else
            {
                Response.Write("<script>alert('Se produjo un error " + HttpContext.Current.Session["arrg"] + " al acceder a la BD.')</script>");
            }
        }

        protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
        {
            // longitud de clave, 24
            string cipherText = RijndaelSimple.Encrypt(ventanaLogin.Password,
                                                        "Pas5pr@se",
                                                        "s@1tValue",
                                                        "SHA1",
                                                        2,
                                                        "@1B2c3D4e5F6g7H8",
                                                        256);

            string resultado = Proxy.login(ventanaLogin.UserName, cipherText);

            if (!resultado.Equals("error"))
            {
                // setting false stops a thread exception from happening
                Response.Redirect(resultado,false);
            }
        }        
    }
}